package com.shiyun.websocketclient.clients;

import com.shiyun.websocketclient.bean.MyWebSocketClient;
import lombok.SneakyThrows;

import java.net.URI;

/**
 * 类 描 述:
 * 作   者: 史 云
 *
 * @author 史 云
 * 版   本: 1.0.0
 * 时   间: 2021年12月30日  15:22:00
 */
public class Client_4 {
    static Boolean isDo = true;

    @SneakyThrows
    public static void main(String[] args) {
        MyWebSocketClient client = new MyWebSocketClient( new URI("ws://localhost:8005/websocket/LOGOFF_NOTICE/4:64378994-d822-49ce-8242-b9a4c237405c"));
        connect(client);
    }

    static void connect(MyWebSocketClient client) throws InterruptedException {
        client.connect();
        Thread.sleep(2_000);
        while (isDo){
            if(!client.isOpen()){
                try {
                    client.reconnect();
                } catch (Exception e) {
                    e.printStackTrace();
                    System.out.println("====================================================================================");
                }
            }
        }
    }
}
